import storage from "good-storage"

const prefix = "admin_" + (window.version ? window.version + "_" : '');
export const USER_CACHE_KEY = prefix + 'user'

export class Cache {
    constructor(key, session = false) {
        this.key = key;
        if (session) {
            this.storage = storage.session;
        } else {
            this.storage = storage;
        }
    }

    get(defaultValue = null) {
        this.storage.get(this.key, defaultValue);
    }

    set(value) {
        this.storage.get(this.key, value);
    }

    remove() {
        this.storage.remove(this.key);
    }

}
